﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _5._2
{
    public partial class mainFrm : Form
    {
        public mainFrm()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void BtnLogin_Click(object sender, EventArgs e)
        {
            bool result = false;
            //获取信息
            string userName = TxtLogin.Text;
            string password = TxtPwd.Text;
            //非空验证
            if (userName==""|| password =="")
            {
                MessageBox.Show("账户跟密码不能为空！");
            }
           
            //执行处理
           string sql= string.Format("select*from Am where Admin='{0}' and pwd='{1}'",userName,password);
            //调用检索方法
          SqlDataReader dr=  DBHelper.Select(sql);
            while (dr.Read())
            {
                MessageBox.Show("登陆成功！");
                result = true;
                break;
            }
            dr.Close();
            if (!result)
            {
                MessageBox.Show("登陆失败！");
            }
        }
    }
}
